package com.gimi.cloud.bbp.client.controller.order;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.gimi.cloud.bbp.client.service.order.SettlementService;
import com.gimi.cloud.bbp.common.utils.reqhead.Util;
import com.gimi.cloud.bbp.dto.mall.MallCartDTO;
import com.gimi.cloud.bbp.dto.mall.SettlementDTO;
import com.gimi.cloud.bbp.dto.order.OrderDTO;
import com.gimi.cloud.bbp.dto.order.ShOrderPayinfoDTO;

/**
 * 商品结算
 * @author 李林峰
 * @version 1.0
 * @Description
 * @create 2018年1月25日
 */
@RestController
@RequestMapping(value = "/settlement")
public class SettlementController {
	@Autowired SettlementService settlementService;
	
	@RequestMapping(value = "/generatingClearingInformation")
	public void generatingClearingInformation(@RequestBody SettlementDTO settlementInfo,HttpServletResponse response) {
		Util.sendResponse(JSON.toJSONString(settlementService.generatingClearingInformation(settlementInfo)),response);
	}

	@RequestMapping(value = "/generatingOrder")
	public void generatingOrder(@RequestBody SettlementDTO settlementInfo,HttpServletResponse response) {
		Util.sendResponse(JSON.toJSONString(settlementService.generatingOrder(settlementInfo)),response);
	}
	
	@RequestMapping(value = "/submissionOfPaymentStatus")
	public void generatingOrder(@RequestBody ShOrderPayinfoDTO payinfoDTO,HttpServletResponse response) {
		Util.sendResponse(JSON.toJSONString(settlementService.submissionOfPaymentStatus(payinfoDTO)),response);
	}
	
	@RequestMapping(value = "/buyDirect")
	public void buyDirect(@RequestBody MallCartDTO maCart,HttpServletResponse response) {
		Util.sendResponse(JSON.toJSONString(settlementService.buyDirect(maCart)),response);
	}
	
	@RequestMapping(value = "/getPaymentParameters")
	public void getPaymentParameters(@RequestBody OrderDTO order,HttpServletResponse response) {
		Util.sendResponse(JSON.toJSONString(settlementService.getPaymentParameters(order)),response);
	}
	
	@RequestMapping(value = "/getOrderPayAmount")
	public void getOrderPayAmount(@RequestBody OrderDTO order,HttpServletResponse response) {
		Util.sendResponse(JSON.toJSONString(settlementService.getOrderPayAmount(order)),response);
	}
	
	
}